package App;

import Controls.*;
import Core.*;

public class TestForm extends Form implements TweenInterface
{
	ContextMenu cmenu = new ContextMenu(this);
    Tween t;

	public TestForm()
	{
		super(Form.HEAD | Form.THIN_PANEL);

		setWindowText(GM.FORM_CAPTION, "Form1");
		setWindowText(GM.PANEL_RIGHTSOFT, "Exit");
		setWindowText(GM.PANEL_LEFTSOFT, "Menu");

		body.h_border = 3;
		body.scrollEnable = true;

		/*Group g2 = new Group(body, "Font options");

		g2.addControl(new Button("Play", g2));
		g2.addControl(new Button("Pause", g2));
		g2.addControl(new Button("Default font", g2));

		Group gr = new Group(body, "Sliders");

		gr.addControl(new Slider(gr.getAvailableW()));
		gr.addControl(new Slider(gr.getAvailableW()));
		gr.addControl(new Slider(gr.getAvailableW()));

		Group g3 = new Group(body, "Colors");

		g3.addControl(new ColorSelector(0xff0000, 40, true));
		g3.addControl(new ColorSelector(0x00ff00, 40, true));
		g3.addControl(new ColorSelector(0x0000ff, 40, true));

		ContextMenu m1 = new ContextMenu(this);
		ContextMenu m2 = new ContextMenu(this);

		m1.addAction(new ContextAction("Some action", 10, null));
		m1.addAction(new ContextAction("Some action", 11, null));
		m1.addAction(new ContextAction("Back", 12, cmenu));

		m2.addAction(new ContextAction("Some action", 20, null));
		m2.addAction(new ContextAction("Some action", 21, null));
		m2.addAction(new ContextAction("Back", 22, cmenu));

		cmenu.addAction(new ContextAction("To submenu 1", 1, m1));
		cmenu.addAction(new ContextAction("To submenu 2", 2, m2));
		cmenu.addAction(new ContextAction("Some action", 3, null));
         */

        body.addControl(new TweenTestControl(body.getAvailableW(), 50));

		body.select(Control.UNDER);

        t = new Tween(this, 1000);
	}

	public void onEvent(int event, Object param)
	{
		super.onEvent(event, param);

		if(event == GM.CONTROL_RELEASED)
		{
			Control control = (Control) param;
			if(control.getCaption().equals("Play"))  t.enable();
			if(control.getCaption().equals("Pause")) t.disable();
		}
		
		if(event == GM.PANEL_RIGHTSOFT) HelloMIDlet.instance.exitMIDlet();

		if(event == GM.PANEL_LEFTSOFT)
		{
			Control c;
			c = body.getRealActiveControl();
			Point p = c.getCoord();
			p.y += c.getH();
			
			//cmenu.show(p);
		}
	}

    public void tweenTick(Tween t)
    {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
}
